<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column v-if="columns.visible('id')" prop="id" label="ID" />
        <el-table-column v-if="columns.visible('empName')" prop="empName" label="姓名" />
        <el-table-column v-if="columns.visible('sex')" prop="sex" label="性别" />
        <el-table-column v-if="columns.visible('birthday')" prop="birthday" label="出生日期">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('idCard')" prop="idCard" label="身份证" />
        <el-table-column v-if="columns.visible('join')" prop="join" label="入所时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.join, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('nativePlace')" prop="nativePlace" label="籍贯" />
        <el-table-column v-if="columns.visible('nation')" prop="nation" label="民族" />
        <el-table-column v-if="columns.visible('highestEdu')" prop="highestEdu" label="最高学历" />
        <el-table-column v-if="columns.visible('highestDegree')" prop="highestDegree" label="最高学位" />
        <el-table-column v-if="columns.visible('firstSchool')" prop="firstSchool" label="学校1（本科）" />
        <el-table-column v-if="columns.visible('firstMajor')" prop="firstMajor" label="专业1" />
        <el-table-column v-if="columns.visible('secondSchool')" prop="secondSchool" label="学校2（研究生）" />
        <el-table-column v-if="columns.visible('secondMajor')" prop="secondMajor" label="专业2" />
        <el-table-column v-if="columns.visible('title')" prop="title" label="职称" />
        <el-table-column v-if="columns.visible('titleBeginTime')" prop="titleBeginTime" label="获得此职称的时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.titleBeginTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('professionalLevel')" prop="professionalLevel" label="专业等级" />
        <el-table-column v-if="columns.visible('phone')" prop="phone" label="手机号" />
        <el-table-column v-if="columns.visible('relationMember')" prop="relationMember" label="联系人" />
        <el-table-column v-if="columns.visible('familyPhone')" prop="familyPhone" label="联系人手机号" />
        <el-table-column v-if="columns.visible('address')" prop="address" label="家庭住址（详细）" />
        <el-table-column v-if="columns.visible('maritalStatus')" prop="maritalStatus" label="婚姻情况" />
        <el-table-column v-if="columns.visible('childrenSituation')" prop="childrenSituation" label="子女情况" />
        <el-table-column v-if="columns.visible('politicsStatus')" prop="politicsStatus" label="政治面貌" />
        <el-table-column v-if="columns.visible('secretLevel')" prop="secretLevel" label="涉密等级" />
        <el-table-column v-if="columns.visible('workerNumber')" prop="workerNumber" label="工作证编号" />
        <el-table-column v-if="columns.visible('email')" prop="email" label="邮箱" />
        <el-table-column v-if="columns.visible('centerBelong')" prop="centerBelong.centerName" label="所属中心" />
        <el-table-column v-if="columns.visible('leaveTime')" prop="leaveTime" label="离职时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.leaveTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('leaveReason')" prop="leaveReason" label="离职原因" />
        <el-table-column v-if="columns.visible('leaveInf')" prop="leaveInf" label="离职说明" />
        <!-- <el-table-column v-permission="['admin','employeeBase:edit','employeeBase:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudEmployeeBase from '@/api/employeeBase'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import pagination from '@crud/Pagination'

// crud交由presenter持有
const defaultCrud = CRUD({ title: '人员基本信息', url: 'api/employeeBase', sort: 'id,asc', crudMethod: { ...crudEmployeeBase }})
const defaultForm = { id: null, empName: null, sex: null, birthday: null, idCard: null, join: null, nativePlace: null, nation: null, highestEdu: null, highestDegree: null, firstSchool: null, firstMajor: null, secondSchool: null, secondMajor: null, title: null, titleBeginTime: null, professionalLevel: null, phone: null, relationMember: null, familyPhone: null, address: null, maritalStatus: null, childrenSituation: null, politicsStatus: null, secretLevel: null, workerNumber: null, email: null, centerBelong: { id: null }, leaveTime: null, leaveReason: null, leaveInf: null }
export default {
  name: 'EmployeeBase',
  components: { pagination },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      permission: {
        add: ['admin', 'employeeBase:add'],
        edit: ['admin', 'employeeBase:edit'],
        del: ['admin', 'employeeBase:del']
      }
    }
  },
  created() {
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      this.crud.params['id'] = this.$route.query.id
      return true
    }
  }
}
</script>

<style scoped>

</style>
